package com.zb.vo;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.zb.annotation.NumberPattern;
import com.zb.entity.ZjNetworkSet;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * @Author WEN
 * @Date 2023/7/26 0026
 **/
@Data
@ApiModel("服务区域实体封装")
public class NetworkSetVo {
    @NotNull(message = "服务区域ID不能为空")
    @ApiModelProperty(value = "服务区域ID，必传", required = true, example = "")
    private Long id;

    @NotNull(message = "区域限制不能为空")
    @NumberPattern(regexp = "^(1|2|3)$", required = true, message = "区域限制参数不合法")
    @ApiModelProperty(value = "区域限制：1-无区域限制，2-区域优先，3-限制区域", required = true, example = "1")
    private Integer sectorise;

    @ApiModelProperty(value = "创建时间", hidden = true)
    private Date createTime;

    @ApiModelProperty(value = "更新时间", hidden = true)
    private Date updateTime;


    public static NetworkSetVo beanToVo(ZjNetworkSet networkSet) {
        NetworkSetVo vo = new NetworkSetVo();
        BeanUtils.copyProperties(networkSet, vo);
        vo.setCreateTime(networkSet.getGmtCreate());
        vo.setUpdateTime(networkSet.getGmtUpdate());
        return vo;
    }

    public static ZjNetworkSet voToBean(NetworkSetVo vo) {
        ZjNetworkSet networkSet = new ZjNetworkSet();
        BeanUtils.copyProperties(vo, networkSet);
        return networkSet;
    }
}
